<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    MaintainScrollPositionOnPostback="true" CodeFile="ContactTypes.aspx.cs" Inherits="Admin_ContactTypes"
    Title="APM - Contact Types" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="types">
        <ul id="path">
            <li><a href="../Home.aspx">Home</a> &gt;</li>
            <li>Administration &gt;</li>
            <li>Contact Types</li>
        </ul>
        <h3 class="types"><span>Contact Types</span></h3>
        <div id="content">
            <p>
            </p>
            <table width="100%">
                <tr>
                    <td colspan="2" style="font-weight: bold; height:25px; vertical-align:top">
                        Add new Contact Type
                    </td>
                </tr>
                <tr>
                    <td colspan="2"> 
                    <table cellpadding="0" cellspacing="0" border="0">
                    <tr>
                    <td style="width: 91px;">
                        Contact Type
                    </td>
                    <td>
                        <table cellpadding="0" cellspacing="0">
                            <tr>
                                <td>
                                    <asp:TextBox runat="server" ValidationGroup="Add" ID="txtContactType" Width="100"
                                        MaxLength="50" CssClass="input"></asp:TextBox></td>
                                <td>
                                    &nbsp;&nbsp;Example - Program Manager
                                </td>
                            </tr>
                        </table>
                                      </td>
                    </tr>
                    </table>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:Button runat="server" ValidationGroup="Add" ID="btnSave" Text="Submit" ToolTip="Click to add new Contact Type"
                            CausesValidation="true" OnClick="btnSave_Click" />
                        <asp:ValidationSummary runat="server" ValidationGroup="Add" HeaderText="Please correct the following:"
                            ShowMessageBox="true" ID="valiAllValidations" ShowSummary="false" DisplayMode="BulletList" />
                        <asp:RequiredFieldValidator ID="reqContactType" ValidationGroup="Add" runat="server"
                            SetFocusOnError="true" Display="None" ControlToValidate="txtContactType" ErrorMessage=" Required Field: Contact Type "></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="regexContactType" ValidationGroup="Add" runat="server"
                            ControlToValidate="txtContactType" ErrorMessage="Invalid Input: Contact Type "
                            ValidationExpression="^[a-zA-Z0-9 ]+$" Display="None"></asp:RegularExpressionValidator>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        Existing Contact Types
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:GridView ID="gridContactTypeEnabled" runat="server" AllowPaging="True" AllowSorting="True"
                            DataSourceID="obdsEnableContactTypes" AutoGenerateColumns="False" AutoGenerateEditButton="False"
                            CssClass="table" DataKeyNames="ContactTypeID" OnRowDeleted="gridContactTypeEnabled_RowDeleted"
                            EmptyDataText="No Contact Types has been enabled." OnRowUpdated="gridContactTypeEnabled_RowUpdated"
                            OnRowDataBound="gridContactTypeEnabled_RowDataBound"
                            PageSize="10" ToolTip="This table shows all Enabled Contact Types in the APM System.">
                            <AlternatingRowStyle CssClass="alternate" />
                            <PagerSettings Position="TopAndBottom" />
                            <PagerStyle CssClass="pages" />
                            <EmptyDataRowStyle BackColor="#C4D7D6" BorderStyle="none" />
                            <HeaderStyle HorizontalAlign="Left" />
                            <Columns>
                                <asp:CommandField ValidationGroup="Update" ShowCancelButton="true" ShowDeleteButton="true"
                                    DeleteText="Disable" ShowEditButton="true" HeaderText="Select" ButtonType="link"
                                    CausesValidation="true" HeaderStyle-HorizontalAlign="left" ItemStyle-HorizontalAlign="left">
                                    <ItemStyle Width="110px" Wrap="False" />
                                </asp:CommandField>
                                <asp:TemplateField HeaderText="Contact Type" SortExpression="ContactType">
                                    <ItemTemplate>
                                        <asp:Label runat="server" ID="lblContactType" Text='<%# Microsoft.Security.Application.AntiXss.HtmlEncode(Eval("ContactType").ToString()) %>'></asp:Label>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:TextBox ID="txtContactTypeEdit" runat="Server" Text='<%# Bind("ContactType") %>'
                                            MaxLength="50" CssClass="input" />
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtContactTypeEdit"
                                            Display="None" ErrorMessage=" Required Field: Contact Type " SetFocusOnError="true"
                                            ValidationGroup="Update"></asp:RequiredFieldValidator>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtContactTypeEdit"
                                            Display="None" ErrorMessage="Invalid Input: Contact Type " ValidationExpression="^[a-zA-Z0-9 ]+$"
                                            ValidationGroup="Update"></asp:RegularExpressionValidator>
                                    </EditItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <RowStyle HorizontalAlign="Left" />
                        </asp:GridView>
                        <asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="BulletList"
                            HeaderText="Please correct the following:" ShowMessageBox="true" ShowSummary="false"
                            ValidationGroup="Update" />
                        <asp:ObjectDataSource ID="obdsEnableContactTypes" UpdateMethod="UpdateContactType"
                            runat="server" TypeName="Microsoft.AceEngineering.SPM.SPMBusinessLayer.ContactTypesBL"
                            SelectMethod="GetEnabledContactTypes" OldValuesParameterFormatString="{0}" SortParameterName="dir"
                            DeleteMethod="DisableContactType">
                            <DeleteParameters>
                                <asp:Parameter Name="ContactTypeID" Type="String" />
                            </DeleteParameters>
                            <UpdateParameters>
                                <asp:Parameter Name="ContactTypeID" Type="String" />
                                <asp:Parameter Name="ContactType" Type="String" />
                                <asp:SessionParameter Name="CreatedBy" SessionField="loginname" Type="String" />
                            </UpdateParameters>
                        </asp:ObjectDataSource>
                        <br />
                    </td>
                </tr>
                <tr>
                    <td colspan="2"> 
                        Existing Disabled Contact Types
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:GridView ID="gridContactTypeDisabled" runat="server" AllowPaging="True" AllowSorting="True"
                            DataSourceID="obdsDisableContactTypes" AutoGenerateColumns="False" AutoGenerateEditButton="False"
                            CssClass="table" DataKeyNames="ContactTypeID" EmptyDataText="No Contact Types has been disabled."
                            OnRowDeleted="gridContactTypeDisabled_RowDeleted"
                            PageSize="10" ToolTip="This table shows all Disabled Contact Types in the APM System.">
                            <AlternatingRowStyle CssClass="alternate" />
                            <PagerSettings Position="TopAndBottom" />
                            <PagerStyle CssClass="pages" />
                            <EmptyDataRowStyle BackColor="#C4D7D6" BorderStyle="none" />
                            <HeaderStyle HorizontalAlign="Left" />
                            <Columns>
                                <asp:CommandField HeaderText="Select" ButtonType="link" ShowDeleteButton="true" DeleteText="Enable"
                                    HeaderStyle-HorizontalAlign="left" ItemStyle-HorizontalAlign="left">
                                    <ItemStyle Width="110px" Wrap="False" />
                                </asp:CommandField>
                                <asp:BoundField HeaderText="Contact Type" DataField="ContactType" SortExpression="ContactType"
                                    ReadOnly="True" HtmlEncode="true" >
                                    <ItemStyle Wrap="True" />
                                </asp:BoundField>
                            </Columns>
                            <RowStyle HorizontalAlign="Left" />
                        </asp:GridView>
                        <asp:ObjectDataSource ID="obdsDisableContactTypes" runat="server" TypeName="Microsoft.AceEngineering.SPM.SPMBusinessLayer.ContactTypesBL"
                            SelectMethod="GetDisabledContactTypes" OldValuesParameterFormatString="{0}" SortParameterName="dir"
                            DeleteMethod="EnableContactType">
                            <DeleteParameters>
                                <asp:Parameter Name="ContactTypeID" Type="String" />
                            </DeleteParameters>
                        </asp:ObjectDataSource>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</asp:Content>
